//
//  OptionalModel.m
//  DaiShengInvest
//
//  Created by 张睿 on 2017/7/31.
//  Copyright © 2017年 davinci. All rights reserved.
//

#import "OptionalModel.h"



@implementation OptionalModel



+(instancetype)modelWithDictionary:(NSDictionary *)dic{
    
    OptionalModel *model =[[OptionalModel alloc] init];
    
    [model setValuesForKeysWithDictionary:dic];
    
    return model;
}


+(void)optionalWithSucess:(void (^)(NSArray<OptionalModel *> *))sucessBlock error:(void (^)())errorBlock{
    
    [[NetworkTool sharedTools] POST:@"symbols/optional-list" parameters:nil progress:nil success:^(NSURLSessionDataTask * _Nonnull task, NSDictionary *  _Nullable responseObject) {
        
//        NSLog(@"==%@",responseObject);
        
        NSArray * paramDict = responseObject[@"param"];
        
//        NSArray * dataarray = paramDict[@"data"];
        
        NSMutableArray *mArray = [NSMutableArray array];
        
        [paramDict enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            
            OptionalModel * model = [OptionalModel modelWithDictionary:obj];
            
            [mArray addObject:model];
            
        }];
        
        if(sucessBlock){
            sucessBlock(mArray.copy);
        }
        
    } failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
        
    }];
    
}

-(void)setValue:(id)value forUndefinedKey:(NSString *)key{
}

@end
